package com.googlecode.gingerman.robot;

import com.googlecode.gingerman.world.geometry.Coordinates;
import com.googlecode.gingerman.world.geometry.Vector;

public class Weapon implements AIWeapon {
	private boolean nextFire;
	private Robot robot;
	private double speed, radius, x, y; 
	private int steps, i=5;
	
	public Weapon(Robot robot) 
	{
		this.robot=robot;
		nextFire = false;
		speed = 20;
		steps = 30;
		radius = 7;
	}
	
	public void fire() 
	{
		if (i<=0) {nextFire = true; i=5;}
		else i--;
	}

	public double getSpeed() {
		return speed;
	}

	public double getRadius() {
		return radius;
	}

	public int getSteps() {
		return steps;
	}

	public void step() {
		if (nextFire) {
			i--;
			Vector vector=new Vector(robot.getAngle(), 38);
			Coordinates coordinates=new Coordinates(robot.getX(), robot.getY());
			Vector tmp=new Vector(coordinates);
			vector=vector.add(tmp);
			x=vector.getX();
			y=vector.getY();
			Bullet bullet = new Bullet(x, y, robot.getAngle(), speed, steps, radius);
			nextFire = false;
			robot.getWorld().addBullet(bullet);
			robot.getWorld().addBulletTmpAdd(bullet);
		}
	}

}